{
  "properties" : { },
  "id" : "36122573044d49f69e8284f885ed0825",
  "script" : null,
  "groupId" : "8a4d09d5d4824ed99d9cf45868c29fe1",
  "name" : "删除",
  "createTime" : 1714063371058,
  "updateTime" : 1711901117519,
  "lock" : null,
  "createBy" : "管理员",
  "updateBy" : "管理员",
  "path" : "remove",
  "method" : "DELETE",
  "parameters" : [ {
    "name" : "id",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "Integer",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ {
    "name" : "permission",
    "value" : "system:jggl",
    "description" : "允许拥有该权限的访问",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "requestBody" : "{\"id\":18}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : null,
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import com.gitee.fastmybatis.core.query.Query;

import 'com.wiwf.model.mapper.admin.dao.SysUnitMapper' as sysUnitMapper;
import 'com.wiwf.model.mapper.admin.dao.SysUnitUserRoleMapper' as sysUnitUserRoleMapper;

var unitId = id != null? id: body.id;
if(unitId < 4){
    exit 409, "不能默认单位";
}

Query query = new Query().eq("parent_id", unitId);
if(sysUnitMapper.getCount(query) > 0){
    exit 401, "包含子节点的菜单不能删除！"
}

Query query = new Query().eq('unit_id', unitId);
sysUnitUserRoleMapper.deleteByQuery(query, null);
return sysUnitMapper.deleteById(unitId);